<!doctype html>
<html lang="{{ config('app.locale') }}">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, viewport-fit=cover">
  <meta name="_token" content="{{ csrf_token() }}"/>
  <script>if (location.href.indexOf('qkids.cn/wx') > -1) location.href = location.href.replace('qkids.cn/wx', 'wx2.97kid.com/wx')</script>
  <link href="{{env('CDN_RESOURCE')}}/mobile/campaign/summer/css/summer.css?v={{config('app.version')}}" rel="stylesheet" type="text/css">



  <title>Qkids久趣英语</title>

</head>
<body>

<div class="s-header">
  <div class="logo"></div>
</div>


<div class="christmas-bg">
  <img src="{{env('CDN_RESOURCE')}}/mobile/campaign/summer/img/top_bg_2.jpg?v=20180625">
  <div class="play-icon" id="viewVideo" style="top: 80vw;left: 45vw;"></div>
  <div class="summer-count">第二波</div>
</div>

<div class="wrapper">

  <div class="section" style="padding-top:0;">
    {{--<div class="hot-offer">--}}
    {{--<span>「拼读课专用课时」</span>--}}
    {{--<img src="{{env('CDN_RESOURCE')}}/mobile/campaign/summer/img/group_buy_detail.png">--}}
    {{--<span style="font-size: 14px;color: #999EA8;">使用日期：2018.03.26-04.04</span>--}}
    {{--</div>--}}

    {{--<div class="due-date">--}}
    {{--课时有效期截止至2017年12月31日--}}
    {{--</div>--}}



    {{--<div id="applyGroup" class="reg-btn apply-btn" data-field="{{$campaignProduct['p_id']}}">--}}
    {{--立即开团--}}
    {{--</div>--}}


    <div class="fixed-btns">

      <div class="stick-buyAlone-btn" data-field="{{$extraCampaignProduct['p_id']}}"> ¥350 单独购买</div>
      <div id="applyGroupFix" class="stick-group-btn" data-field="{{$campaignProduct['p_id']}}">
        立即开团
      </div>
    </div>

    <div id="groupBuyDetail" style="position: relative">
      <div class="group-buy-list" id="groupBuyList">

        <div class="captain">
          <img src="{{env('CDN_RESOURCE')}}/mobile/campaign/summer/img/empty.png">
          <span>第1人</span>
        </div>

        <div class="group-member">
          <img src="{{env('CDN_RESOURCE')}}/mobile/campaign/summer/img/empty.png">
          <span>第2人</span>
        </div>

        <div class="group-member">
          <img src="{{env('CDN_RESOURCE')}}/mobile/campaign/summer/img/empty.png">
          <span>第3人</span>
        </div>

        <div class="group-member">
          <img src="{{env('CDN_RESOURCE')}}/mobile/campaign/summer/img/empty.png">
          <span>第4人</span>
        </div>
      </div>

      <div class="g-m-divider">

        <div class="divider">
          <div></div>
          <div></div>
          <div></div>
        </div>

        <div class="divider">
          <div></div>
          <div></div>
          <div></div>
        </div>


        <div class="divider">
          <div></div>
          <div></div>
          <div></div>
        </div>

      </div>

      <div class="group-buy-status" id="groupBuyStatus">
      </div>
    </div>

    <div class="notice">
      成团时间：
      <span class="day">02</span>天
      <span class="hour">00</span>:
      <span class="min">00</span>:
      <span class="sec">00</span>
    </div>

  </div>


  <div class="section" style="padding:10px 0 0 0;">
    <div class="header">
      活动进度
      <div class="title-background"></div>
    </div>
    <div class="camp-step">
      <div class="item">
        <div class="group-buy-step1 icon"></div>
        <span>开团当团长</span>
      </div>
      <div class="item">
        <div class="group-buy-step2 icon"></div>
        <span>参团支付</span>
      </div>
      <div class="item">
        <div class="group-buy-step3 icon"></div>
        <span>邀请好友参团</span>
      </div>
      <div class="item">
        <div class="group-buy-step4 icon"></div>
        <span>团购完成</span>
      </div>
      <div>
        <div class="connect-line"></div>
        <div class="connect-line"></div>
        <div class="connect-line"></div>
      </div>
    </div>
  </div>

  <div class="section" style="padding-bottom: 0;">
    <div class="header">
      活动信息
      <div class="title-background"></div>
    </div>
    <div class="instruction">
      <div>
        <div class="num">1.</div>
        <div class="text">新老用户均可开团、参团享受¥168/10节课(单独购买为¥350/10节课)，每人仅限购买一次，购买成功后可在“预约上课” — “我的” — “优惠券”查询；</div>
      </div>
      <div>
        <div class="num">2.</div>
        <div class="text">本次课券为4人班专享，限量10000份，成功购买后，家长根据孩子的英文水平自主约课；</div>
      </div>
      <div>
        <div class="num">3.</div>
        <div class="text">课券可于08月01日-08月31日期间使用，过期未使用可于09月10日之前办理退费；</div>
      </div>
      <div>
        <div class="num">4.</div>
        <div class="text">新用户购买后请务必微信关注「久趣英语服务号」，通过服务号约课，或咨询客服。</div>
      </div>
    </div>
  </div>

  <div class="section">
    <div class="graduation-icon-c"></div>
    <div class="header">严选北美外教</div>
    <img src="{{env('CDN_RESOURCE')}}/img/mobile/teacher.png">
    <div class="statistic">
      <div class="item">
        <div class="up">1%</div>
        <div class="down">考核通过率</div>
      </div>

      <div class="item">
        <div class="up">100%</div>
        <div class="down">来自美国，加拿大</div>
      </div>

      <div class="item">
        <div class="up">95+</div>
        <div class="down">家长评分</div>
      </div>

    </div>
  </div>

  <div class="section">
    <div class="interest-icon-c"></div>
    <div class="header">趣味教学场景</div>
    <div class="sub-header">孩子到久趣的第一个转变—主动要求上课</div>
    <img src='{{env('CDN_RESOURCE')}}/img/mobile/teaching.png'>

    <div class="lesson-steps">
      <div class="item">
        <div class="photo-icon"></div>
        <div class="text">丰富动画</div>
      </div>


      <div class="item">
        <div class="game-icon"></div>
        <div class="text">游戏化</div>
      </div>


      <div class="item">
        <div class="thumbsup-icon"></div>
        <div class="text">同伴激励</div>
      </div>


    </div>
  </div>

  <div class="section">
    <div class="level-icon-c"></div>
    <div class="header">科学分级课程体系</div>
    <div class="sub-header">
      <span>基于欧洲语言共同框架(CEFR)独家研发，与中国公立小学新课标教材接轨，更适合中国孩子学习</span>
    </div>
    <img src="{{env('CDN_RESOURCE')}}/img/mobile/course_system.png" style="margin-top: 22px;">
    <div class="sub-header">
      <span>即刻连线北美外教，专业指导，进阶升级。</span>
      <span>久趣英语目前已开设自然拼读课、语言基础课，还有更多好学好玩的课程等你发现。</span>
    </div>
  </div>


  <div class="section ">
    <div class="blue-divider"></div>
    <div class="header">特惠价格，即刻报名</div>
    <div class="sub-header">180天无条件退款，报名后即可上课</div>

    <div class="lesson-plan">

      <div class="detail product4 zoom-out">

        <div class="fee">
                        <span class="up">
                            ¥ <span class="money">100</span>
                        </span>
          <span class="down">
                            /4 课时
                        </span>
        </div>

        <div class="schedule">
          <div><span>自购买起，一个月内有效</span></div>
          <div><span>建议4-6节课/周</span></div>
          <div><span>本期招生仅限前500</span></div>
          <div class="reg-btn buy-btn" data-field="4">购买</div>
        </div>

      </div>

      <div class=" detail zoom-in">

        <div class="fee">
                        <span class="up">
                            ¥ <span class="money">3500</span>
                        </span>
          <span class="down">
                            /100 课时
                        </span>
        </div>

        <div class="schedule">
          <div><span>自购买起，课时一年内有效</span></div>
          <div><span>建议4-6节课/周</span></div>
          @if($largeLimit['day'] > 0)
            <div class="reg-btn buy-btn disable" data-field="6">待开放</div>
          @else
            <div class="reg-btn buy-btn" data-field="6">购买</div>
          @endif
        </div>

      </div>

      <div class=" detail zoom-out">

        <div class="fee">
                        <span class="up">
                            ¥ <span class="money">1750</span>
                        </span>
          <span class="down">
                            /50 课时
                        </span>
        </div>

        <div class="schedule">
          <div><span>自购买起，课时90天内有效</span></div>
          <div><span>建议4-6节课/周</span></div>
          @if($largeLimit['day'] > 0)
            <div class="reg-btn buy-btn disable" data-field="5">待开放</div>
          @else
            <div class="reg-btn buy-btn" data-field="5">购买</div>
          @endif
        </div>

      </div>

    </div>
  </div>

  <div class="section">

    <div class="blue-divider"></div>
    <div class="header">简单<span>3</span>步，立即上课</div>

    <div class="lesson-steps" style="margin-top:10px;">
      <div class="item">
        <div class="ok-icon"></div>
        <span>购买课程</span>
      </div>

      <div class="item">
        <div class="chat-icon"></div>
        <span>微信约课</span>
      </div>

      <div class="item">
        <div class="tv-icon"></div>
        <span>进入教室</span>
      </div>
    </div>

    <div class="class-type">
      <div class="c-header">精品2、4人班，每节课30分钟</div>
      <div class="type">
        <div>
          <span>2</span>人班&nbsp<span>2</span>课时/节
        </div>

        <div><span>4</span>人班&nbsp<span>1</span>课时/节</div>

      </div>
    </div>
  </div>

  <div class="section">
    <div class="blue-divider"></div>
    <div class="header">家长说</div>
    <div class="review" id="review">
      <div class="left-r item ">
        <img src="{{env('CDN_RESOURCE')}}/img/mobile/avatar1.png"/>
        <div class="text">喜欢久趣，我们家一天一节课，孩子主动要求的。</div>

        <div class="review-who">
          <span>Mike 的家长</span>
        </div>
      </div>

      <div class="right-r item ">

        <div class="text">全程课小孩自己上完了，完全没让我帮忙。</div>
        <img src="{{env('CDN_RESOURCE')}}/img/mobile/avatar2.png"/>

        <div class="review-who">
          <span>Lorna 的家长</span>
        </div>
      </div>

      <div class="left-r item ">
        <img src="{{env('CDN_RESOURCE')}}/img/mobile/avatar3.png"/>
        <div class="text">现在上课已经成为了小朋友期盼的一件事，真不错！</div>

        <div class="review-who">
          <span>Steve 的家长</span>
        </div>
      </div>

      <div class="right-r item ">

        <div class="text">外教的语音语调都很好听，很地道。</div>
        <img src="{{env('CDN_RESOURCE')}}/img/mobile/avatar4.png"/>

        <div class="review-who">
          <span>Vincent 的家长</span>
        </div>
      </div>

      <div class="left-r item ">
        <img src="{{env('CDN_RESOURCE')}}/img/mobile/avatar5.png"/>
        <div class="text">孩子对语言很敏感，我希望他从小就接触纯正的表达。</div>

        <div class="review-who">
          <span>Alina 的家长</span>
        </div>
      </div>

    </div>

  </div>

  <div class="footer">

    <div class="icon-links">
      <div class="logo-blue"></div>
    </div>

    <div class="qr-code">
      <img src="{{env('CDN_RESOURCE')}}/mobile/campaign/summer/img/wechat_qr_2.png" alt="">
      <span class="name">久趣英语服务号</span>
      <span class="scan-me">扫码关注我，即可约课~</span>
    </div>

    <div id="account-info" style="text-align: center;display: none;margin-top: 10px;color: #676C75;font-size: 14px;">
      当前账号: <span id="current-account"></span> | <span id="switch-account">切换账号</span>
    </div>

    <div class="copy-right">
    </div>

  </div>

  <div class="video-mask" id="videoMask">
    <div class="close-icon icon" id="closeVideo"></div>
    <div id="videoContainer" class="video">
    </div>
    <style>
      .vcp-player {
        margin: 0 auto;
      }
    </style>
  </div>


  <div class="buy-restrict">
    <div class="info">
      您已经购买过 ¥100／4课时，建议您购买长期课时
    </div>

    <a href="/wx/vip">
      <div class="small-btn confirm-btn">前往购买</div>
    </a>

  </div>


  <div class="group-status" id="groupStatus">
    <div class="explanation">

      <div class="top-banner">
        {{--<img class="santa sad-santa"--}}
        {{--src="{{env('CDN_RESOURCE')}}/mobile/campaign/summer/img/sad_santa.png">--}}
        {{--<img class="santa happy-santa"--}}
        {{--src="{{env('CDN_RESOURCE')}}/mobile/campaign/summer/img/happy_santa.png">--}}

      </div>

      <div class="content">
        <div class="group-detail">
          <div class="title"></div>
          <div class="text"></div>
        </div>
        <div class="reg-btn ok-btn" id="okBtn">确定</div>
      </div>
    </div>
  </div>

  <div class="group-status" id="closeBuy">
    <div class="explanation">

      <div class="top-banner"></div>

      <div class="content">
        <div class="group-detail">
          <div class="title">提示</div>
          <div class="text">本期拼读课名额已抢完，请您留意微信"久趣英语服务号"的招募推送，我们下期见~</div>
        </div>
        <div style="text-align: center;">
          <div class="reg-btn ok-btn" style="width: 80%; display: inline-block;" id="cancelBtn1" onclick="document.getElementById('closeBuy').style.display='none'">取消</div>
        </div>
      </div>

    </div>
  </div>

  <div class="group-status" id="confirmBuy">
    <div class="explanation">

      <div class="top-banner"></div>

      <div class="content">
        <div class="group-detail">
          <div class="title">提示</div>
          <div class="text">拼读课程目前推出L1级别，适合4-6岁，零基础或有半年以内英语基础的孩子学习。请确认是否报名。</div>
        </div>
        <div style="text-align: center;">
          <div class="reg-btn ok-btn" style="width: 35%; display: inline-block;margin-right: 5%;background-color: #85D84B;" id="buy-btn">购买</div>
          <div class="reg-btn ok-btn" style="width: 35%; display: inline-block;" id="cancelBtn" onclick="document.getElementById('confirmBuy').style.display='none'">取消</div>
        </div>
      </div>

    </div>
  </div>

  <div class="buy-restrict">
    <div class="info">
      您已经购买过 ¥100／4课时，建议您购买长期课时
    </div>

    <a href="/wx/vip">
      <div class="small-btn confirm-btn">前往购买</div>
    </a>

  </div>


  <div class="share-mask">
    <div class="share-arrow"></div>
    {{--<div class="share-text">点击分享给好友 ^ _ ^ </div>--}}
  </div>

  <div id="alertBox" class="alert-box"></div>

</div>

<script type="text/javascript" src="https://static-app.97kid.com/wx/js/zepto.min.js"></script>
<!--引入微信js-SDK-->
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript" src=" {{env('CDN_RESOURCE')}}/js/mobile/wx_config.js?v={{config('app.version')}}"></script>
<script type="text/javascript" src="{{env('CDN_RESOURCE')}}/js/mobile/Zepto_fx_methods.js"></script>
<script type="text/javascript" src="{{env('CDN_RESOURCE')}}/js/mobile/login.js?v={{config('app.version')}}"></script>
<script type="text/javascript" src="{{env('CDN_RESOURCE')}}/js/AV.analytics.js"></script>


<script type="text/javascript">

  (function ($) {

    $(function () {
      if (utils.getUrlParam('alert') === 'qrcode') {
        $('#groupStatus .text').text('微信关注【久趣英语服务号】才能上课')
        $('#groupStatus').show()
      }
      if (!utils.getQueryString('_c')) {
        var QKidsChannel = JSON.parse(window.localStorage.getItem('QKidsChannel'))
        if (!(QKidsChannel && QKidsChannel.expires > new Date().getTime() / 1000)) {
          window.localStorage.setItem('QKidsChannel', JSON.stringify({
            rawData: 'summers_share',
            expires: new Date().getTime() / 1000 + 24 * 3600
          }))
        }
      }

      var CDN_RESOURCE = "{{env('CDN_RESOURCE')}}"
      var currentLevel = 1
      var previousLevel = 1
      var offset = 5
      var isInWechat = false
      var userAgent = navigator.userAgent
//      var userAgent = "Mozilla/5.0(iphone;CPU iphone OS 5_1_1 like Mac OS X) AppleWebKit/534.46(KHTML,like Geocko) Mobile/9B206 MicroMessenger/5.0";
      var wechatInfo = userAgent.match(/MicroMessenger\/([\d\.]+)/i)
      if (wechatInfo) {
        isInWechat = true
      }
      var analytics = AV.analytics({
        appId: 'antYy9lOFi5mkU9QKjtYmRLM-gzGzoHsz',
        appKey: 'jqyWxLyobpsmdwsJddJlDheb',
        channel: isInWechat ? 'weixin' : ''
      });

      // 微信活动逻辑
      {
        var configOption = {
          timestamp: '{{$signature['timestamp']}}',
          nonceStr: '{{$signature['nonceStr']}}',
          signature: '{{$signature['signature']}}',
          jsApiList: ['onMenuShareTimeline', 'chooseWXPay', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareQZone']
        }
        var gid = getGId();
        var wxconfig = new WxConfig(configOption, 'summers')
        var shareFlag = ''
        var shareMsg = function () {
          return {
            title: '久趣暑假8月优惠丨￥168/10节课，在家和北美外教学英语',
            desc: '4-12岁使用，4人成团，在家和北美外教学英语。',
            link: window.location.protocol + '//wx2.97kid.com/wx/summers' + Math.ceil(Math.random() * 100) + '?_c=summers&_r=' + shareFlag + (gid ? '&gid=' + gid : ''),
            imgUrl: 'https://static-app.97kid.com/site-student/public/img/share.png',
            success: function (target) {
              analytics.send({
                event: 'p003-summers-share',
                attr: {
                  gid: gid
                }
              });
            }
          }
        }
        wxconfig.activeShare(shareFlag, '', shareMsg())
        var account = new Account()
        var groupBuyStatus = 0
        var campaignEnd = 1535731199
        var creator = 0

        analytics.send({
          event: 'p003-summer-open',
          attr: {
            gid: gid
          }
        });

        function getGId () {
          var gid = '{{$gid}}'
          if (!gid) {
            var path = localStorage.getItem('QKidsPathname')

            function getMatched (name, string) {
              if (string) {
                var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)')
                var len = string.indexOf('?') == 0 ? 1 : 0
                var r = string.substr(len).match(reg)
                if (r != null) return unescape(r[2])
              }
              return null
            }

            var localGid = getMatched('gid', decodeURIComponent(path))
            if (localGid) gid = localGid
          }
          return gid
        }

        account.forceLogin = false
        account.getUserInfo(function (err, userInfo) {
          gid = getGId()
          console.log(gid);
          if (!err && userInfo && userInfo.shareFlag) {
            $('#switch-account').text('切换账号');
            shareFlag = userInfo.shareFlag
            wxconfig.activeShare(shareFlag, '', shareMsg())
          }
          if (gid || !err) {
            getGroupBuyInfo(gid)
          }
          var weChatCode = utils.getQueryString('code');
          var authCallback = account.getAuthCallback();
          if (!err && weChatCode && authCallback) {
            try {
              eval(authCallback);
            } catch (e) {
              console.log(e);
            }
          }
          account.setAuthCallback();
        })

        //提交订单
        $('.stick-group-btn, .stick-buyAlone-btn').click(function () {
          if (groupBuyStatus === 3 && groupBuyStatus === 7) {
            window.location.href = '/wx'
          } else if (groupBuyStatus === 2 || groupBuyStatus === 1) {
            $('.share-mask').fadeIn()
          } else {
            submitOrder($(this).attr('data-field'))
          }
        });
        $('#buy-btn').click(function () {
          if (groupBuyStatus === 3 && groupBuyStatus === 7) {
            window.location.href = '/wx'
          } else if (groupBuyStatus === 2 || groupBuyStatus === 1) {
            $('.share-mask').fadeIn()
          } else {
            $('#confirmBuy').hide();
            submitOrder($(this).attr('data-field'))
          }
        });

        //关闭提示窗口
        $('#okBtn').click(function () {
          $('#groupStatus').fadeOut()
        })

        //关闭分享提示
        $('.share-mask').click(function () {
          $(this).fadeOut()
        })

        function submitOrder (pId) {
          account.setAuthCallback("submitOrder(" + pId + ')');
          var campUrl = window.location.protocol + '//' + window.location.host + '/wx/summers' + Math.ceil(Math.random() * 100) + '?alert=qrcode';
          var campPara = {
            gid: getGId(),
          }
          account.forceLogin = true
          //提交订单久趣后台
          account.getUserInfo(function (userInfoError, userInforesult) {
            if (userInfoError) {
              $.toastAlert(userInfoError.message)
            } else {
              $('#switch-account').text('切换账号');
              if (isInWechat) {
                //配置微信分享接口
                shareFlag = userInforesult.shareFlag
                wxconfig.activeShare(shareFlag, '', shareMsg())
              }
              var payChannel = isInWechat ? 'weixin' : 'alipay';
              account.ajax({
                type: 'GET',
                path: '/s/customers/' + window.localStorage.getItem(account.openId) + '/status',
                success: function (status) {
                  account.ajax({
                    type: 'POST',
                    path: '/s/bills',
                    data: {
                      productId: pId,
                      payChannel: payChannel,
                      returnUrl: status.subscribe ? window.location.protocol + '//' + window.location.host + '/wx/summers' + Math.ceil(Math.random() * 100) : window.location.protocol + '//' + window.location.host + '/wx/verifypayment/' + pId + '?campUrl=' + encodeURIComponent(campUrl) ,
                      tradeType: 'JSAPI',
                      openId: window.localStorage.getItem(account.openId),
                      groupBuyingId: groupBuyStatus === 5 ? '' : encodeURIComponent(decodeURIComponent(campPara['gid']))
                    },
                    success: function (data) {
                      //唤起微信支付
                      if (data.status !== 'error') {
                        analytics.send({
                          event: 'p003-summers-buy',
                          attr: {
                            gid: gid,
                            pid: pId,
                            payChannel: payChannel
                          }
                        });
                        if (isInWechat) {
                          var jsApiParameters = JSON.parse(data.jsApiParameters)
                          if (status.subscribe) jsApiParameters.redirect = window.location.protocol + '//' + window.location.host + '/wx/summers' + Math.ceil(Math.random() * 100)
                          wxconfig.pay(data.bill_id, pId, jsApiParameters, encodeURIComponent(campUrl))
                        } else {
                          window.location.href = data.url
                        }
                      } else {
                        $.toastAlert('下单失败，请重试')
                      }
                    },
                    error: function (err) {
                      if (err.code === 'product.rejected.by.bought.products') {
                        $.toastAlert('您已经参加活动')
                        getGroupBuyInfo()
                      }
                    }
                  })
                },
                error: function (err) {
                  $.toastAlert(err.message, 2)
                }
              })
            }
          })
        }

        {{--function getGroupByResult() {--}}
        {{--account.ajax({--}}
        {{--type: 'POST',--}}
        {{--path: '/s/groupbuy',--}}
        {{--data: {--}}
        {{--groupBuyingId: '{{$gid}}',--}}
        {{--},--}}
        {{--success: function (data) {--}}
        {{--if (data.status !== 'error') {--}}
        {{--setGroupBuyCountDown(data.endAt);--}}
        {{--getGroupBuyerList(data.buyers);--}}

        {{--} else {--}}
        {{--//$.toastAlert('下单失败，请重试');--}}
        {{--}--}}
        {{--},--}}
        {{--error: function (err) {--}}
        {{--//                        $.toastAlert(err.message, 2);--}}
        {{--}--}}
        {{--});--}}
        {{--}--}}

        function getGroupBuyInfo (gid) {
          //已经登陆
          if (!gid) {
            account.ajax({
              type: 'POST',
              path: '/s/products/{{$campaignProduct['p_id']}}/buying',

              success: function (result) {
                //已经开团
                creator = result.creatorId
                setGroupBuyStatus(result, true)
                getGroupBuyerList(result.buyers.toString())
                resetShareDetail(result.id)

              },
              error: function (err) {
                setGroupBuyStatus(err, false)
              }
            })
          } else {
            account.ajax({
              auth: false,
              type: 'POST',
              path: '/s/products/{{$campaignProduct['p_id']}}/buying',
              data: {groupBuyingId: encodeURIComponent(gid)},//'fsxz2CTal9g%3D'},
              success: function (result) {
                //已经开团
                creator = result.creatorId
                setGroupBuyStatus(result, true)
                getGroupBuyerList(result.buyers.toString())
                resetShareDetail(result.id)
              },
              error: function (err) {
                setGroupBuyStatus(err, false)
              }
            })
          }
        }

        function getGroupBuyerList (buyers) {
          account.ajax({
            auth: false,
            type: 'GET',
            path: '/s/students/socials',
            data: {ids: buyers},
            success: function (result) {
              showGroupBuyerList(result)
            },
            error: function (err) {
              $.toastAlert(err.message, 2)
            }
          })
        }

        function showGroupBuyerList (wechatInfoList) {

          var referralListHtml = ''
          var sortedList = []

          if (creator !== 0) {
            var captain
            var currentBuyer
            var currentBuyerId = 0
            if (JSON.parse(window.localStorage.getItem(account.userInfoKey)) !== null) {
              currentBuyerId = JSON.parse(window.localStorage.getItem(account.userInfoKey)).id
            }

            for (var k = 0; k < wechatInfoList.length; k++) {
              if ((wechatInfoList[k].id) === creator) {
                captain = wechatInfoList[k]
              } else if (wechatInfoList[k].id === currentBuyerId) {
                currentBuyer = wechatInfoList[k]
              } else {
                sortedList.push(wechatInfoList[k])
              }
            }

            if (currentBuyerId !== creator && currentBuyer) {
              sortedList.unshift(currentBuyer)
            }

            if (captain) {
              sortedList.unshift(captain)
            }
          }

          var buyers = [' ', 'A', 'B', 'C']

          for (var i = 0; i < Math.min(4, sortedList.length); i++) {

            if (i === 0) {
              referralListHtml += '<div class="captain">' +
                '<div class="flag-icon"></div>' +
                '<img src="' + getAvatar(sortedList[i].avatar) + '" onerror="this.src=\'' + CDN_RESOURCE + '/mobile/campaign/summer/img/empty.png\'">' +
                '<span>' + sortedList[i].nickname + '</span>' +
                '</div>'
            } else {
              referralListHtml += '<div class="group-member">' +
                '<img src="' + getAvatar(sortedList[i].avatar) + '" onerror="this.src=\'' + CDN_RESOURCE + '/mobile/campaign/summer/img/empty.png\'">' +
                '<span>' + sortedList[i].nickname + '</span>' +
                '</div>'
            }

          }

          for (var j = 0; j < (4 - sortedList.length); j++) {
            referralListHtml += '<div class="group-member">' +
              '<img src="' + '{{env('CDN_RESOURCE')}}' + '/mobile/campaign/summer/img/empty.png" />' +
              '<span>第' + (sortedList.length + j + 1) + '人</span>' +
              '</div>'
          }

          $('#groupBuyList').empty().append(referralListHtml)

        }

        function getAvatar (avatar) {
          if (!avatar) {
            return '{{env('CDN_RESOURCE')}}' + '/img/mobile/campaign/doubleEleven/pic_avatar_boy.png'
          }
          return avatar
        }

        var starCount = null

        function setGroupBuyCountDown (status, endAt) {
          if (starCount) clearInterval(starCount)
          if (status == 0) {
            starCount = setInterval(function () {

              var timestamp = Date.parse(new Date())
              if (timestamp >= endAt) {
                // 团购已经结束
                $('.notice').text('该团购已经到期!')
                clearInterval(starCount)

              } else if (timestamp < endAt) {
                var timeDiff = endAt - timestamp
                var day = Math.floor(timeDiff / 1000 / 60 / 60 / 24)
                var hour = Math.floor(timeDiff / 1000 / 60 / 60 % 24)
                var min = Math.floor(timeDiff / 1000 / 60 % 60)
                var sec = Math.floor(timeDiff / 1000 % 60)

                if (day < 10) {
                  day = '0' + day
                }
                if (hour < 10) {
                  hour = '0' + hour
                }
                if (min < 10) {
                  min = '0' + min
                }
                if (sec < 10) {
                  sec = '0' + sec
                }
                var countDownTime = hour + ':' + min + ':' + sec
                $('.notice').text('成团时间: ' + day + '天' + countDownTime)
                $('.notice .day').text(day)
                $('.notice .hour').text(hour)
                $('.notice .min').text(min)
                $('.notice .sec').text(sec)
              }
            }, 1000)

          } else if (status == 1) {
            $('.notice').text('已成团')
          } else {
            $('.notice').text('已过期')
          }

        }

        //已登陆

        //setGroupBuyStatus({}, true);
        function setGroupBuyStatus (gpDetail, status) {

          if (!gpDetail || !gpDetail.id) return;

          //  status: 1->已报名 2->未报名

//                alert(groupBuyTimeStatus(gpDetail.endAt) + '-'  + campaignTimeStatus());

          var currentBuyerId = 0
          if (JSON.parse(window.localStorage.getItem(account.userInfoKey)) !== null) {
            currentBuyerId = JSON.parse(window.localStorage.getItem(account.userInfoKey)).id
          }

          var inGroup = gpDetail.buyers && gpDetail.buyers.indexOf(currentBuyerId) >= 0

          var cStatus = campaignTimeStatus()

          var endAt1 = new Date().getTime() / 1000 + 1000
          var endAt2 = new Date().getTime() / 1000 - 1000

          //status = true;
          //cStatus = true;
          //inGroup = true;

          // 组团中
          //gpDetail = { id: 1, status: 2, buyerCount: 2, endAt: endAt1, buyers: [9]};
          // 团成功
          //gpDetail = { id: 1, status: 1, buyerCount: 4, endAt: endAt2, buyers: [7,8,9,27]};
          // 团过期
          //gpDetail = { id: 1, status: 2, buyerCount: 4, endAt: endAt2, buyers: [9]};

          setGroupBuyCountDown(gpDetail.status, gpDetail.endAt * 1000)
          if (status) {
            if (gpDetail.status === 0) {
              if (inGroup) displayGroupBuyStatus(2, gpDetail.buyerCount)
              else displayGroupBuyStatus(8, gpDetail.buyerCount)
            } else if (gpDetail.status === 1) {
              if (inGroup) displayGroupBuyStatus(1)
              else {
                if (cStatus) displayGroupBuyStatus(5)
                else displayGroupBuyStatus(7)
              }
            } else {
              if (cStatus) {
                if (inGroup) displayGroupBuyStatus(4)
                else displayGroupBuyStatus(6)
              } else {
                if (inGroup) displayGroupBuyStatus(3)
                else displayGroupBuyStatus(7)
              }
            }
          }
        }

        function groupBuyTimeStatus (groupBuyEnd) {
          return (new Date).getTime() / 1000 <= groupBuyEnd
        }

        function campaignTimeStatus () {
          return (new Date).getTime() / 1000 <= campaignEnd
        }

        function displayGroupBuyStatus (status, buyerCounter) {
          $('.camp-step .icon').removeClass('active')
          if (status === 1) {
            $('.group-buy-step4').addClass('active')
            //happy monkey
            // 团购成功( 已报名 已成团 活动时间未到期 )
            //亲爱的家长，您已成功购入暑期第二波团购（￥168/10节课），北美外教给您准备了有趣的课程，快去预约上课吧！
            $('.apply-btn, .stick-group-btn').css('width', '100%').text('团购成功，分享给好友')
            $('.stick-buyAlone-btn').hide()

            $('.group-buy-status').text('当前团购成功')
            // $('.happy-santa').show().siblings('.santa').hide()
            $('#groupStatus .title').text('团购成功')
            if (new Date().getTime() > 1533052800000) $('#groupStatus .text').text('亲爱的家长，您已成功购入暑期第二波团购（￥168/10节课），北美外教给您准备了有趣的课程，快去预约上课吧！')
            else $('#groupStatus .text').text('亲爱的家长，您已成功购入暑期第二波团购（￥168/10节课），北美外教给您准备了有趣的课程，课劵有效期2018年8月1日-8月31日！')
            $('#groupStatus').show()
            groupBuyStatus = 1

          } else if (status === 2) {
            //尚未成团 (已报名 团没有满 团购时间未到期 活动时间还没到期  )
            $('.apply-btn , .stick-group-btn').css('width', '100%').text('邀请好友参团')
            $('.stick-buyAlone-btn').hide()

            $('.group-buy-status').text(' 还差' + (4 - buyerCounter) + '人即可成团，邀请更多好友共享')
            $('#top-btn').text('立即邀请')
            groupBuyStatus = 2
            $('.group-buy-step3').addClass('active')

          } else if (status === 3) {
            //normal monkey
            //活动已结束( 已报名 团没有满 团购时间到期 活动时间已到期)
            //亲爱的家长，您所在的团未在规定时间内组团成功，系统将在3个工作日为您自动退款，请注意查收。点击查看其他优惠活动吧。
            $('.apply-btn, .stick-group-btn').text('查看其他优惠').hide()
            $('.stick-buyAlone-btn').css('width', '100%')

            $('.group-buy-status').text('暑期第二波团购活动已结束')
            // $('.sad-santa').show().siblings('.santa').hide()
            $('#groupStatus .title').text('活动已结束')
            $('#groupStatus .text').text('亲爱的家长，您所在的团未在规定时间内组团成功，系统将在3-5个工作日为您自动退款，请注意查收。点击查看其他优惠活动吧。')
            $('#groupStatus').show()
            groupBuyStatus = 3

          } else if (status === 4) {
            $('.group-buy-step1').addClass('active')
            //sad monkey
            //很遗憾( 已报名 团没有满 团购时间到期 活动时间未到期)
            //亲爱的家长，您所在的团未在规定时间内组团成功，系统将在3个工作日为您自动退款，请注意查收。活动还未结束，重新开团抢购暑期第二波团购优惠吧。
            $('.apply-btn, .stick-group-btn').text('重新开团')
            $('.group-buy-status').text('未能组团成功，请重新开团')
            // $('.sad-santa').show().siblings('.santa').hide()
            $('#groupStatus .title').text('很遗憾')
            $('#groupStatus .text').text('亲爱的家长，您所在的团未在规定时间内组团成功，系统将在3-5个工作日为您自动退款，请注意查收。活动还未结束，重新开团抢购暑期第二波团购优惠吧。')
            $('#top-btn').text('重新开团')
            $('#groupStatus').show()
            groupBuyStatus = 4

          } else if (status === 5) {
            $('.group-buy-step4').addClass('active')
            //normal monkey
            // 该团已满，重新开团( 未报名 团已满 活动时间未到期 )
            //亲爱的家长，该团已满员，请您重新开团抢购暑期第二波团购优惠吧。
            $('.apply-btn, .stick-group-btn').text('重新开团')
            $('.group-buy-status').text('该团已满员，请重新开团')
            // $('.sad-santa').show().siblings('.santa').hide()
            $('#groupStatus .title').text('该团已满，重新开团')
            $('#groupStatus .text').text('亲爱的家长，该团已满员，请您重新开团抢购暑期第二波团购优惠吧。')
            $('#groupStatus').show()
            $('#top-btn').text('重新开团')
            groupBuyStatus = 5

          } else if (status === 6) {
            //sad monkey
            //请重新开团(  未报名 团没有满 团购时间已经到期 活动时间未到期)
            //亲爱的家长，该团已结束，请您重新开团抢购暑期第二波团购优惠吧。
            $('.apply-btn, .stick-group-btn').text('重新开团')
            $('.group-buy-status').text('该团团购时间结束，请重新开团')
            // $('.sad-santa').show().siblings('.santa').hide()
            $('#groupStatus .title').text('请重新开团')
            $('#groupStatus .text').text('亲爱的家长，该团团购时间结束，请您重新开团抢购暑期第二波团购优惠吧。')
            $('#groupStatus').show()
            groupBuyStatus = 6
            $('.group-buy-step1').addClass('active')

          } else if (status === 7) {
            //normal monkey
            //活动已结束( 未报名 活动时间到期 )
            //亲爱的家长，活动已结束，点击查看其他优惠活动吧。
            $('.apply-btn, .stick-group-btn').text('查看其他优惠').hide()
            $('.stick-buyAlone-btn').css('width', '100%')

            $('.group-buy-status').text('活动已经结束')
            $('.normal-santa').show().siblings('.santa').hide()
            $('#groupStatus .title').text('活动已结束')
            $('#groupStatus .text').text('亲爱的家长，活动已结束，点击查看其他优惠活动吧。')
            $('#groupStatus').show()
            groupBuyStatus = 7
          } else if (status === 8) {
            //参加活动( 未报名 团购活动没有满 活动时间未到期 )
            $('.apply-btn, .stick-group-btn').text('立即参团')
            $('.group-buy-status').text(' 还差' + (4 - buyerCounter) + '人即可成团，邀请更多好友共享')
            groupBuyStatus = 8
            $('.group-buy-step2').addClass('active')
          } else if (status === 9) {
            //参加活动( 未报名 团购活动没有满 团购时间到期 活动时间未到期 )
            $('.apply-btn, .stick-group-btn').text('重新开团')
            $('.group-buy-status').text('该团已结束，请重新开团')
            groupBuyStatus = 9
          }
        }

        function resetShareDetail (_gid) {
          var campPara = []
          campPara['gid'] = _gid
          gid = _gid
          account.getUserInfo(function (err, result) {
            if (!err && isInWechat) {
              //配置微信分享接口
              shareFlag = result.shareFlag
              wxconfig.activeShare(shareFlag, '', shareMsg())
            }
          })

        }

        //切换账号
        $('#switch-account').off('click').on('click',function() {
          $('.account-mask').fadeOut();
          account.forceLogin = true;
          account.checkLoginStatus(function() {
            account._showLogin(function () {}, true);
          });
        });
      }




      {
        var totalPlans = 3;
        var clickItem = null;
        $('.lesson-plan .detail').on('click', function () {
          $(this).addClass('zoom-in').removeClass('zoom-out');
          $(this).siblings('div').each(function () {
            if ($(this).hasClass('zoom-in')) {
              $(this).removeClass('zoom-in').addClass('zoom-out');
            }
          })

          if ($(this).index() === ( totalPlans - 1 )) {
            clickItem = $('.lesson-plan .detail').eq(0);
            $('.lesson-plan .detail').eq(0).remove();
            $('.lesson-plan').append(clickItem);
          }

          if ($(this).index() === 0) {
            clickItem = $('.lesson-plan .detail').eq(totalPlans - 1);
            $('.lesson-plan .detail').eq(totalPlans - 1).remove();
            $('.lesson-plan').prepend(clickItem);
          }
        });
      }

      {
        var products = {
          1: 100,
          2: 1750,
          3: 3500,
          4: 5000,
        };
        //提交订单
        $('.buy-btn').off('click').on('click', function () {
          submitMainOrder($(this).attr('data-field'));
        });
        $('.disable').off('click');

        function submitMainOrder(pId) {
          account.forceLogin = true;
          //提交订单久趣后台
          account.getUserInfo( function (userInfoError, userInforesult){

            if(userInfoError) {
              $.toastAlert(userInfoError.message);
            } else {
              if (isInWechat) {
                //配置微信分享接口
                wxconfig.activeShare(userInforesult.shareFlag);
              }
              account.ajax({
                type: 'POST',
                path: '/s/bills',
                data: {
                  productId: pId,
                  payChannel: isInWechat ? 'weixin' : 'alipay',
                  returnUrl: window.location.protocol + '//' + window.location.host + '/wx/verifypayment1/' + pId,
                  tradeType: 'JSAPI',
                  openId: window.localStorage.getItem(account.openId)
                },
                success: function (data) {
                  //唤起微信支付
                  if (data.status !== 'error') {
                    if (isInWechat) {
                      wxconfig.pay(data.bill_id, pId, JSON.parse(data.jsApiParameters))
                    } else {
                      window.location.href = data.url
                    }
                  } else {
                    $.toastAlert('下单失败，请重试')
                  }
                },
                error: function (err) {
                  if (pId == 1 && err.code === 'recharge.level.not.applicable.to.user') {
                    $('.buy-restrict').fadeIn();
                  } else {
                    $.toastAlert(err.message, 2);
                  }
                }
              });

            }

          });
        }
      }

      {
        var timeout;
        $(document).bind("scroll", function () {

          clearTimeout(timeout);
          timeout = setTimeout(function () {

            var reviewList = $('#review');
            if ($(window).scrollTop() > reviewList.offset().top - 300) {

              if (reviewList.css('visibility') === 'hidden') {
                reviewList.css('visibility', 'visible');
                reviewList.find('.item').each(function () {
                  $(this).addClass('fade-animate');
                })
              }
            }
          }, 10);
        });
      }
    })

  })(window.Zepto)


</script>

<script src="//imgcache.qq.com/open/qcloud/video/vcplayer/TcPlayer-2.2.1.js" charset="utf-8"></script>
<script>
  $(function () {
    //初始化视频
    var player = new TcPlayer(
      //页面放置播放位置的元素 ID
      'videoContainer',
      {
        'm3u8': 'http://1251352844.vod2.myqcloud.com/45f5686avodtransgzp1251352844/3b4dc3f34564972818953227732/v.f20.mp4',
        'autoplay': false,
        'coverpic': '',
        'width': '640',
        'height': '480',
        'live': false,
        'systemFullscreen': true,
      })

    //观看视频
    $('#viewVideo').click(function () {
      $('#videoMask').fadeIn(300)
      player.play()
    })

    //关闭视频
    $('#closeVideo').click(function () {
      player.pause()
      $('#videoMask').fadeOut(300)
    })
  })
</script>


</body>
</html>